﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using SmartParking.Data.Entities;
using ADEVSO.Util;
using SmartParking.Bussiness;
using System.ComponentModel;
using System.Web;

namespace SmartParking.Web.Models
{
    public class CustomersModel
    {
        public CustomerModel Customer;

        public List<CustomerModel> Customers { get; set; }

        public CustomersModel()
        {
            Customers = CustomerModel.LoadCustomers();
            Customer = new CustomerModel();
        }
    }

    public class CustomerModel
    {
        [Required]
        [Display(Name = "Cliente")]
        public int CustomerID { get; set; }

        [Required(ErrorMessage = "Nombre del cliente requerido.")]
        [Display(Name = "Nombre")]
        [DataType(DataType.Text)]
        [StringLength(50)]
        public string Name { get; set; }

        [Required(ErrorMessage = "Email del cliente requerido.")]
        [Display(Name = "Email")]
        [DataType(DataType.Text)]
        [StringLength(75)]
        public string Email { get; set; }

        [Required(ErrorMessage = "Teléfono del cliente requerido.")]
        [Display(Name = "Teléfono")]
        [DataType(DataType.Text)]
        [StringLength(12)]
        public string Phone { get; set; }

        [Required(ErrorMessage = "Dirección del cliente requerida.")]
        [Display(Name = "Dirección")]
        [DataType(DataType.Text)]
        [StringLength(100)]
        public string Address { get; set; }

        public static List<CustomerModel> LoadCustomers()
        {
            List<CustomerModel> Customers = new List<CustomerModel>();

            foreach (var cust in ParkingManager.GetCustomers())
            {
                Customers.Add(new CustomerModel() { CustomerID = cust.CustomerID, Name = cust.Name, Email = cust.Email, Address = cust.Address, Phone = cust.Phone });
            }

            return Customers;
        }
    }
}
